﻿using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using ASPItalia.ModelVirtualCasting.Parts;
using System.Data.Entity;

namespace ASPItalia.ModelVirtualCasting.EntityFramework
{
    [Export("LanguageRepository", typeof(ILanguageRepository))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    [RepositoryMetadata(Name = "LanguageRepository", IsFake = false)]
    public class LanguageRepository : BaseRepository<Language>, ILanguageRepository
	{
        [ImportingConstructor()]
		public LanguageRepository(IContextContainer container) : base(container)
        {
        }

		public IQueryable<Language> GetAll()
		{
			return CurrentSet;
		}

		public IQueryable<Language> Where(Expression<Func<Language, bool>> predicate)
		{
			return CurrentSet.Where(predicate);
		}

		public long Count(Expression<Func<Language, bool>> predicate)
		{
			return CurrentSet.Count(predicate);
		}

		public ILanguageRepository Include<TProperty>(Expression<Func<Language, TProperty>> path)
		{
			IncludeInternal(path);
			return this;
		}

		public ILanguageRepository Include(string path)
		{
			IncludeInternal(path);
			return this;
		}

		public ILanguageRepository CreateQuery()
		{
			CreateQueryInternal();
			return this;
		}

		public ILanguageRepository EnableLazyLoading()
		{
			SetLazyLoading(true);
			return this;
		}

		public ILanguageRepository DisableLazyLoading()
		{
			SetLazyLoading(false);
			return this;
		}

		public ILanguageRepository DoNotTrack()
		{
			base.DoNotTrackInternal();
			return this;
		}
	}
}